#include<bits/stdc++.h>
using namespace std;
#define int long long

int d[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int mp[] = {13, 1, 2, 3, 5, 4, 4, 2, 2, 2};

signed main() {
	int ans = 0;
	for (int dates = 20000101; dates <= 20240413; dates++) {
		int years = dates / 10000;
		int months = dates / 100 % 100;
		int days = dates % 100;

		if ((years % 4 == 0 && years % 100 != 0) || (years % 400 == 0))
			d[2] = 29;
		else
			d[2] = 28;

		if (months > 12 || months < 1)
			continue;
		if (days < 1 || days > d[months])
			continue;

		int sum = 0;
		sum += mp[years / 1000] + mp[years / 100 % 10] + mp[years / 10 % 10] + mp[years % 10];
		sum += mp[months / 10] + mp[months % 10];
		sum += mp[days / 10] + mp[days % 10];
		if (sum > 50)
			ans++;
	}
	cout << ans;
	return 0;
}
